package com.rdc.rdcmusicapp.playingActivity;

import androidx.appcompat.app.AppCompatActivity;

import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;

import com.rdc.rdcmusicapp.R;
import com.rdc.rdcmusicapp.bean.LocalMusicBean;
import com.rdc.rdcmusicapp.mainActivity.MainActivity;

public class PlayingActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView textViewNowPro;
    private TextView textViewAllPro;
    private ImageView imageViewArtist;
    private TextView textViewArtist;
    private TextView textViewTitle;
    private ImageView imageViewReturn;

    SeekBar seekBar;
    private LocalMusicBean song;
    ObjectAnimator animator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.playing_activity);
        //获取传来的歌曲
        song = (LocalMusicBean) getIntent().getExtras().getSerializable("song");
        initView();
        //设置旋转动画
        animator = ObjectAnimator.ofFloat(imageViewArtist, "rotation", 0f, 360f);
        animator.setDuration(50000);// 持续时间 - 决定了播放的快慢
        animator.setInterpolator(new LinearInterpolator());
        animator.setRepeatCount(-1);
        animator.start();

        setSong(song);

    }

    @Override
    public void onClick(View view) {
        if(view.getId() == R.id.imageViewReturn )
        {
            //返回选择列表
            this.finish();
        }
    }

    private void initView() {
        textViewNowPro = findViewById(R.id.textViewNowPro);
        textViewAllPro = findViewById(R.id.textViewAllPro);
        textViewArtist = findViewById(R.id.textViewArtist);
        textViewTitle = findViewById(R.id.textViewTitle);
        imageViewArtist = findViewById(R.id.imageViewArtist);
        seekBar = findViewById(R.id.seekBar);
        imageViewReturn = findViewById(R.id.imageViewReturn);
        imageViewReturn.setOnClickListener(this);
    }
    public void setSong(LocalMusicBean song) {
        // 获取音乐相关信息
        textViewTitle.setText(song.getmSong());
        textViewArtist.setText(song.getmSinger());
        textViewAllPro.setText(song.getmDuration());
    }
}

